<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 分组交换两个乘数位置
        var str = "123*456";
        // 替换
        // 外部捕获
        console.log(str.replace(/([0-9]+)\*([0-9]+)/, "$2*$1"));
        // 内部捕获
        console.log(/([0-9]+)\*(\1)/.test(str));
        console.log(/([0-9]+)\*(\1)/.test("123*123"));
    </script>
</body>
</html>